package com.dyh.quickdemo.leqeeDb;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.web.client.RestTemplate;

import java.util.List;

/*
@Author=Joey Wheeler
@Date=2020/10/16 11:30
*/
@SpringBootTest
@Slf4j
public class OmsPost {

    public static String url = "https://databasehub.leqee.com/api/QuickQueryController/syncExecute";
    public static int dbId = 40;//内贸bi库

    @Autowired
    RestTemplate restTemplate;

    @Test
    public void test(){
        OmsPost omsPost = new OmsPost();
        Req req = new Req();
        req.setDatabase_id(dbId);
        req.setSql("select count(1) from omssync.sync_order_info where create_time > '2020-10-31'");
        req.setToken("3547e22149241a73678cf4863118e8845f9d5a6419284");
        String raw = restTemplate.postForObject(url,req,String.class);
        //Rsp rsp = restTemplate.postForObject(url,req,Rsp.class);
//        log.info("res={}", JSON.toJSONString(rsp));
        log.info("res={}", raw);
    }

    /**
     * database_id : 36
     * sql : select * from fairjob.group order by group_id desc limit 500
     * token : b6cba3e6d69948981ef9075d21ed48e35f89069e44c8b
     */
    @Setter@Getter
    static class Req{
        private int database_id;
        private String sql;
        private String token;
    }

    @Setter@Getter
    static class Rsp{
        private String code;
        private Data data;
        @Setter@Getter
        static class Data{
            private List<JSONObject> data ;
        }

    }

    public static void main(String[] args) {
        Long l1 = 10L;
        Long l2 = 10L;

        System.out.println(l1.equals(l2));
    }





}
